<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!-- Testing if static or dynamic include -->
<c:if test="${param.page != null}">
	<c:set var="page" value="${param.page}" />
</c:if>
<c:if test="${param.pagingDiff != null}">
	<c:set var="pagingDiff" value="${param.pagingDiff}" />
</c:if>
<c:if test="${param.minshown != null}">
	<c:set var="minshown" value="${param.minshown}" />
</c:if>
<c:if test="${param.maxshown != null}">
	<c:set var="maxshown" value="${param.maxshown}" />
</c:if>
<c:if test="${param.pagecount != null}">
	<c:set var="pagecount" value="${param.pagecount}" />
</c:if>
<c:if test="${param.orderby != null}">
	<c:set var="orderby" value="${param.orderby}" />
</c:if>
<c:if test="${param.desc != null}">
	<c:set var="desc" value="${param.desc}" />
</c:if>
<c:if test="${param.currentPage != null}">
	<c:set var="currentPage" value="${param.currentPage}" />
</c:if>
<c:set var="prefix" value=""/>
<c:if test="${param.prefix != null}">
	<c:set var="prefix" value="${param.prefix}" />
</c:if>

<c:set var="method" value="setpage" />
<c:choose>
	<c:when test="${(!empty param.ajax) && param.ajax}">
		<c:set var="method" value="ajax_setpage" />
		<input type="hidden" id="ajax_current_page" value="${page }" />
		<input type="hidden" id="ajax_current_orderby" value="${orderby }" />
		<input type="hidden" id="ajax_current_desc" value="${desc }" />
	</c:when>
	<c:otherwise>
		<form id="pagingOrderingForm" method="GET" action="<c:url value="/paging"/>">
			<input type="hidden" name="page" id="page" value="${page }" />
			<input type="hidden" name="orderby" id="orderby" value="${orderby }" />
			<input type="hidden" name="desc" id="desc" value="${desc }" /> 
			<input type="hidden" name="pagingOrderGetParams" id="pagingOrderGetParams" />
			<input type="hidden" name="currentPage" id="currentPage" value="${currentPage }" />
			<input type="hidden" name="prefix" id="prefix" value="${prefix }"/>
		</form>
	</c:otherwise>
</c:choose>
<div class="pull-mid">
	<div class="pagination clickable">
		<ul>
			<!-- Pager -->
			<c:if test="${page!=1}">
				<li><a onclick="${method}(1)">&lt;&lt;</a></li>
				<li><a onclick="${method}(${page-1})">&lt;</a></li>
			</c:if>

			<c:if test="${page>pagingDiff }">
				<li class="disabled"><span>...</span></li>
			</c:if>

			<c:if test="${minshown!=page }">
				<c:forEach var="i" begin="${minshown }" end="${page-1 }" step="1">
					<li><a onclick="${method}(${i})">${i }</a></li>
				</c:forEach>
			</c:if>

			<li class="active"><a href="#">${page }</a></li>

			<c:if test="${maxshown!=page }">
				<c:forEach var="i" begin="${page+1 }" end="${maxshown }" step="1">
					<li><a onclick="${method}(${i})">${i }</a></li>
				</c:forEach>
			</c:if>

			<c:if test="${pagecount-page>pagingDiff }">
				<li class="disabled"><span>...</span></li>
			</c:if>

			<c:if test="${page!=pagecount}">
				<li><a onclick="${method}(${page+1})">&gt;</a></li>
				<li><a onclick="${method}(${pagecount})">&gt;&gt;</a></li>
			</c:if>

		</ul>
	</div>
</div>